package com.yj.timecapsule.service.ai.impl;

import com.alibaba.cloud.ai.tongyi.chat.TongYiChatClient;
import com.yj.timecapsule.service.ai.ChatAiService;
import jakarta.annotation.Resource;
import org.springframework.ai.chat.prompt.Prompt;
import org.springframework.stereotype.Service;

import java.util.Optional;

/**
 * @author Sean
 * @CreateTime 2024-08-05  11:11
 * @Description
 * @Version 1.0
 */
@Service
public class ChatAiServiceImpl implements ChatAiService {
    @Resource
    private TongYiChatClient chatClient;
    @Override
    public String call(String payload) {
        Prompt prompt = new Prompt(payload);
        String content = chatClient.call(prompt).getResult().getOutput().getContent();
        return content;
    }
}
